<?php
function reequipment_user_lookup_parts()
{
	// reminder, as you add phases, they need to be added to the allowed input.
    if (!xarVarFetch('phase', 'enum:part_number:description:man_part_number', $phase, 'part_number', XARVAR_NOT_REQUIRED, XARVAR_PREP_FOR_DISPLAY)) return;
    if (!xarVarFetch('q', 'str:1:', $q, '', XARVAR_NOT_REQUIRED)) return;    
    
    if (!xarSecurityCheck('EditEquipment', 1)) return;
    $data = array();
    	
    switch(strtolower($phase)) {
        case 'part_number':
            $data['parts'] = xarModAPIFunc('reequipment', 'user', 'lookup_parts', array('search_part_number' => $q));
        break;

        case 'description':
        	$data['parts'] = xarModAPIFunc('reequipment', 'user', 'lookup_parts', array('search_description' => $q));
        break;
         
        case 'man_part_number':
        	$data['parts'] = xarModAPIFunc('reequipment', 'user', 'lookup_parts', array('search_man_part_number' => $q));
        break;  

    }
    
    return $data;
}

?>